package snl;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

class BoardPanel extends JPanel {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public BoardPanel() {
        setBorder(BorderFactory.createLineBorder(Color.black));
    }

    public Dimension getPreferredSize() {
        return new Dimension(640,640);
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);       

        Graphics2D g2d = (Graphics2D) g;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				BoardCell cell = new BoardCell().create(i, j);
				g2d.setColor((i+j)%2==0 ? GameUtility.LIGHT_RED : GameUtility.LIGHT_BLUE);
				g2d.fill(cell.getBox());
				Point p = cell.getNumberPosition();
				g2d.setColor(Color.BLACK);
				g2d.drawString(cell.getNumber(), p.x, p.y);
			}
		}
        
    }
    
}
